package com.hllxd.hism.star.basic.service.service;

import com.alibaba.fastjson.JSON;
import com.hllxd.hism.star.basic.service.model.rock.YarnQuotaEntity;
import com.hllxd.hism.star.basic.service.dao.mapper.mis.YarnQuotaMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xiyong.lxy
 * @date 2020-10-12 16:51
 */
@Slf4j
@Service("yarnQuotaService")
public class YarnQuotaServiceImpl implements YarnQuotaService {

    @Autowired
    private YarnQuotaMapper yarnQuotaMapper;


    @Override public YarnQuotaEntity getYarnQuota(Long id) {
        return yarnQuotaMapper.getYarnQuota(id);
    }

    @Override
    public Long setYarnQuota(YarnQuotaEntity entity) {
        log.info("set param: {}", JSON.toJSONString(entity));
        if(entity.id==null || entity.id==0) {
            log.info("will insert entity.");
            return yarnQuotaMapper.insertYarnQuota(entity);
        } else {
            log.info("will update entity.");
            return yarnQuotaMapper.updateYarnQuota(entity);
        }
    }

    @Override
    public List<YarnQuotaEntity> listYarnQuota() {
        return yarnQuotaMapper.listYarnQuota();
    }

    @Override
    public Boolean deleteYarnQuota(String ids) {
        return yarnQuotaMapper.deleteYarnQuota(ids);
    }
}
